package cn.maxwell.HysTrixFactory;

import cn.maxwell.FeiClient.ProductFeiGinClient;
import cn.maxwell.domain.Product;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class ProductFeignClientFallbackFactory implements FallbackFactory<ProductFeiGinClient> {
    @Override
    public ProductFeiGinClient create(Throwable throwable) {
        return new ProductFeiGinClient() {
            @Override
            public Product loadById(Long id) {
                Product product = new Product();
                product.setId(-1L);
                product.setName("服务不可达！");
                product.setPrice(0.0);
                return product;
            }
        };
    }
}
